home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
235_01
/
ovdef.c
< prev
next >
Wrap
Text File
|
1987-06-16
|
14KB
|
413 lines
/* 010 14-Feb-87 ovdef.c
Copyright (c) 1987 by Blue Sky Software. All rights reserved.
*/
#include <stdio.h>
#include "ov.h"
#ifndef NULL
#define NULL (0)
#endif
#define FIRST_AROW (3) /* attribute display */
#define FIRST_ACOL (30)
#define FIRST_TROW (3) /* text types */
#define FIRST_TCOL (2)
#define FIRST_IROW (14) /* instructions/directions */
#define FIRST_ICOL (2)
#define V_bar (0xba)
#define H_bar (0xcd)
extern unsigned char vid_mode; /* need to know video mode */
extern unsigned char vid_snow; /* NZ when checking for snow */
extern unsigned char vid_attrib; /* we hack directly with video attrib */
extern unsigned char def_display; /* NZ when define screen displayed */
extern unsigned char attribs[], cgaattr[], monattr[]; /* arrays of attrib's */
extern char *ovname; /* might be name of OV file */
extern char *cantopen; /* common text message */
extern char patchstr[]; /* id's patch area in EXE file */
extern struct menu_selection top_file_menu[], *top_menu;
extern char *quit_txt;
int def_color(), def_snow(), def_exit();
int def_set(), def_noset(), def_reset(), def_write();
static struct menu_selection set_attr_menu[] = {
{ "Set", "Set the video attributes to the values shown", def_set, NULL },
{ "Reset", "Reset the video attributes to the default values", def_reset, NULL },
{ "Quit", "Quit without changing the video attributes", def_noset, NULL },
{ NULL, NULL, NULL, NULL }
};
static struct menu_selection top_def_menu[] = {
{ "Colors", "Select video display attributes", def_color, set_attr_menu },
{ "Snow", "Enable or disable video \"snow\" checking", def_snow, NULL },
{ "Write", "Make current settings permanent by writing to disk", def_write, NULL },
{ "Quit", "Return to the file display", def_exit, top_file_menu },
{ NULL, NULL, NULL, NULL }
};
static struct { /* define stuff to display the type of */
char *name; /* parameter to be defined - this table */
unsigned char row; /* must be in DIS_NORM - DIS_TAGD order */
unsigned char col;
} def_text[] = {
{ "NORMAL TEXT ", FIRST_TROW, FIRST_TROW },
{ "HIGHLIGHTED TEXT ", FIRST_TROW+1, FIRST_TROW },
{ "WINDOW TEXT ", FIRST_TROW+2, FIRST_TROW },
{ "HIGHLIGHTED WINDOW TEXT", FIRST_TROW+3, FIRST_TROW },
{ "HEADING TEXT ", FIRST_TROW+4, FIRST_TROW },
{ "BACKGROUND TEXT ", FIRST_TROW+5, FIRST_TROW },
{ "TAGGED FILE NAME TEXT ", FIRST_TROW+6, FIRST_TROW } };
static char *directions[] = {
"PgUp & PgDn select the ", "type of text to be set.",
" ", "\x18\x19\x1b\x1a select the colors." };
static int text_type;
static unsigned char newattr[7];
static unsigned char defining = FALSE; /* NZ - video attributes being def'd */
static char *ovfile = "ov.exe";
static char *nowrit = " - current settings not written";
char *getenv(), *strchr();
FILE *fopen(), *pathopen();
/*****************************************************************************
D E F I N E
*****************************************************************************/
define() { /* allow user to define screen colors / snow checking */
def_display = TRUE; /* define screen display is active */
strncpy(newattr,attribs,sizeof(newattr)); /* start with current attribs */
def_init(); /* actually setup the display */
top_menu = top_def_menu; /* make define menu THE menu */
}
/*****************************************************************************
D E F _ E X I T
*****************************************************************************/
static int
def_exit() { /* leave define screen parameters mode */
def_display = FALSE; /* going back to normal */
top_menu = top_file_menu; /* file menu again */
setup_file_scr();
update_header(); /* rewrite the entirey screen */
refresh_screen(0); /* to use possible new colors */
}
/*****************************************************************************
D E F _ I N I T
*****************************************************************************/
static int
def_init() { /* initialize the define screen */
int i, fg;
register int bg;
/* initialize the screen image */
setvattrib(DIS_NORM);
clr_scr();
center_text(0,"DEFINE SCREEN PARAMETERS");
disp_status(); /* status line */
setvattrib(DIS_BOX); /* box to enclose text types */
popup(FIRST_TROW-1,FIRST_TCOL-1,9,27,NULL);
for (i = DIS_NORM; i <= DIS_TAGD; i++) /* display text types */
select_t(0,i);
setvattrib(DIS_BOX); /* box to enclose pattern */
popup(FIRST_AROW-1,FIRST_ACOL-1,18,50,NULL);
for (fg = 0; fg < 16; fg++) { /* display color pattern */
gotorc(FIRST_AROW+fg,FIRST_ACOL);
for (bg = 0; bg < 8; bg++) {
vid_attrib = (bg << 4) | fg;
disp_str(" TEXT ");
}
}
setvattrib(DIS_NORM); /* back to "Normal" */
}
/*****************************************************************************
D E F _ C O L O R
*****************************************************************************/
static int
def_color() { /* define screen "colors" */
int i;
defining = TRUE; /* yes, we are defining attributes */
select_t(1,text_type = DIS_NORM); /* highlight normal text first */
select_a(1,newattr[text_type]); /* highlight current attr location */
top_menu = set_attr_menu; /* so ESC doesn't leave this menu */
setvattrib(DIS_BOX); /* box for directions/instructions */
popup(FIRST_IROW-1,FIRST_ICOL-1,6,27,NULL);
for(i = 0; i < 4; i++)
disp_str_at(directions[i],FIRST_IROW+i,FIRST_ICOL+1);
setvattrib(DIS_NORM);
}
/*****************************************************************************
D E F _ x S E T
*****************************************************************************/
static int
def_set() { /* use the currently displayed video attributes */
strncpy(attribs,newattr,sizeof(newattr)); /* SET the current values */
do_set(); /* rest of stuff */
}
static int
def_noset() { /* back to the prior values */
strncpy(newattr,attribs,sizeof(newattr)); /* back to current */
do_set();
}
static int
def_reset() { /* reset to overview default */
strncpy(attribs,vid_mode == 7 ? monattr : cgaattr,sizeof(newattr));
strncpy(newattr,attribs,sizeof(newattr)); /* back to default */
do_set();
}
static int
do_set() {
defining = FALSE; /* not defining anymore */
def_init(); /* redisplay scr with new vals */
top_menu = top_def_menu; /* back to def menu */
}
/*****************************************************************************
D E F _ S N O W
*****************************************************************************/
static int
def_snow() {
int ch;
char msg[80];
static char *enable = "ENABLE", *disable = "DISABLE";
strcpy(msg,"\"snow\" checking is currently ");
strcat(msg,vid_snow ? enable : disable);
strcat(msg,"D, do you want to ");
strcat(msg,vid_snow ? disable : enable);
strcat(msg," it? (y/N): ");
ch = ask(msg); /* ask user what to do */
if (yes(ch))
vid_snow = vid_snow ? 0 : 1;
}
/*****************************************************************************